﻿using Macro_stone.DtoModel;
using Macro_stone.PoModel;
using Macro_stone.Service.SystemManager;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using SystemCenterSoa.ApiProject.Area.SystemManager;
using SystemCenterSoa.DtoModel.Common;

namespace Macro_stone_Api.Area.SystemManager
{
    [Route("api/[controller]/[action]")]
    [ApiController]

    public class CustomerInputController : SystemManagerBaseController
    {
        private CustomerInputService _CustomerInputService;
        public CustomerInputController (CustomerInputService CustomerInputService)
        {
            _CustomerInputService = CustomerInputService;
        }

        /// <summary>
        /// 添加基本信息
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultModel<bool> CustomerPoAdd(CustomerPo view)
        {
            try
            {
                view.createTime = DateTime.Now;
                view.createName = LoginUser.user_name;
                var data = _CustomerInputService.CustomerPoAdd(view);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<bool>(ex);
            }
        }

        /// <summary>
        /// 添加甲方负责人
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultModel<bool> ResponsiblePersonPoAdd(ResponsiblePersonPo view)
        {
            try
            {
                var data = _CustomerInputService.ResponsiblePersonPoAdd(view);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<bool>(ex);
            }
            
        }
        /// <summary>
        /// 添加满意度调查
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultModel<bool> SatisfactionSurveyPoAdd(SatisfactionSurveyPo view)
        {
            try
            {
                var data = _CustomerInputService.SatisfactionSurveyPoAdd(view);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<bool>(ex);
            }
        }

        /// <summary>
        /// 添加文件
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultModel<bool> AccessoryPoAdd(AccessoryPo view)
        {
            try
            {
                var data = _CustomerInputService.AccessoryPoAdd(view);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<bool>(ex);
            }
        }



        /// <summary>
        /// 客户信息—显示(基础列表)
        /// </summary>
        /// <param name="searchModel"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultModel<List<CustomerPo>> CustomerPoInquire(int pageIndex, int pageSize, int? createTime, string customerName, DateTime? beginTime, DateTime? endTime, string customerSerialNum, string linkman)
        {
            try
            {
                var data = _CustomerInputService.CustomerPoInquire(pageIndex, pageSize, createTime, customerName, beginTime, endTime, customerSerialNum, linkman);
                int totalCount = data.Count();
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<List<CustomerPo>>(ex);
            }
        }

        /// <summary>
        /// 联系人信息—显示
        /// </summary>
        /// <param name="searchModel"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultModel<List<CustomerPo>> ResponsiblePersonPoInquire(int pageIndex, int pageSize, string personName, DateTime? entryTime, DateTime? abortTime)
        {
            try
            {
                var data = _CustomerInputService.ResponsiblePersonPoInquire(pageIndex, pageSize, personName, entryTime, abortTime);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<List<CustomerPo>>(ex);
            }
        }

        /// <summary>
        /// 联系人信息—反填
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
       [HttpGet]
        public ResultModel<bool> ResponsiblePersonPoBackfill(int id)
        {
            try
            {
                var data = _CustomerInputService.ResponsiblePersonPoBackfill(id);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<bool>(ex);
            }
        }

        /// <summary>
        /// 项目前期信息—显示
        /// </summary>
        /// <param name="searchModel"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultModel<List<AccessoryPo>> AccessoryDtoInquire(int pageIndex, int pageSize, string wenName, DateTime? begintime, DateTime? endtime)
        {
            try
            {
                var data = _CustomerInputService.AccessoryDtoInquire(pageIndex, pageSize, wenName, begintime, endtime);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<List<AccessoryPo>>(ex);
            }
        }

        /// <summary>
        /// 项目前期信息—删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultModel<bool> AccessoryDtoDelete(int ids)
        {
            try
            {
                var data = _CustomerInputService.AccessoryDtoDelete(ids);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<bool>(ex);
            }

        }

        /// <summary>
        /// 项目前期信息—反填一条
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultModel<AccessoryPo> AccessoryPoOne(int id)
        {
            try
            {
                var data = _CustomerInputService.AccessoryPoOne(id);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<AccessoryPo>(ex);
            }

        }

        /// <summary>
        /// 项目前期信息—编辑
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
       [HttpPost]
        public ResultModel<bool> AccessoryDtoEdits(AccessoryPo view)
        {
            try
            {
                var data = _CustomerInputService.AccessoryDtoEdits(view);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<bool>(ex);
            }
        }
        /// <summary>
        /// 项目前期信息—添加
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultModel<bool> AccessoryDtoAdd(AccessoryPo view)
        {
            try
            {
                var data = _CustomerInputService.AccessoryDtoAdd(view);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<bool>(ex);
            }
        }

    }
}
